package com.huidz.calendar.mainadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.huidz.calendar.R;

import java.util.ArrayList;

public class HomeAdapter extends BaseAdapter {
    ArrayList<String> list;
    Context context;

    public HomeAdapter(ArrayList<String> list, Context context) {
        // TODO Auto-generated constructor stub
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list != null ? list.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list != null ? list.get(position) : 0;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView = LayoutInflater.from(context).inflate(R.layout.fragment_homelistitem, null);
        init i = new init();
        i.homeitem_text = convertView.findViewById(R.id.homeitem_text);
        i.homeitem_type = convertView.findViewById(R.id.homeitem_type);
        i.homeitem_img = convertView.findViewById(R.id.homeitem_img);
        i.homeitem_hot = convertView.findViewById(R.id.homeitem_hot);
        convertView.setTag(i);
        return convertView;
    }

    public static class init {
        //首页list的子控件
        TextView homeitem_text, homeitem_type;
        ImageView homeitem_hot, homeitem_img;
    }
}

